BigDFT.IO module

This module defines some tools used for reading/writing fragment files.

read_pdb(ifile, include_chain=False, disable_warnings=False, ignore_connectivity=False, ignore_unit_cell=False)[source]

Read a system from a PDB file.

Parameters
  • ifile (TextIOBase) – the file to read from.

  • disable_warnings (bool) – whether to print warnings about possible file issues.

  • include_chain (bool) – include the chain id if True

  • ignore_connectivity (bool) – if True do not store the information about the connectivity matrix.

  • ignore_unit_cell (bool) – assumes free boundary conditions if true.

Warning

This will read in the connectivity information from the pdb as well. However, a pdb file does not provide any information about the bond order. Thus, the bond order of each bond will be set to one.

Returns

the system file.

Return type

(BigDFT.Systems.System)

read_xyz(ifile, fragmentation='atomic')[source]

Read a system from an xyz file. XYZ files do not contain any information about fragments, so this routine will make each atom its own fragment.

Parameters
  • ifile (TextIOBase) – the file to read from.

  • fragmentation (str) – either “atomic” or “single”.

Returns

the system file.

Return type

(BigDFT.Systems.System)

write_pdb(system, ofile)[source]

Write out a system to a string in the pdb format.

Parameters
  • system (BigDFT.Systems.System) – the system to write.

  • ofile (TextIOBase) – the output stream to write to.

read_mol2(ifile, disable_warnings=False)[source]

Read a system from a mol2 file.

Parameters
  • ifile (TextIOBase) – the file to read from.

  • disable_warnings (bool) – whether to print warnings about possible file issues.

Returns

the system file.

Return type

(BigDFT.Systems.System)

write_mol2(system, ofile)[source]

Write out a system to a string in the mol2 format.

Parameters
  • system (BigDFT.Systems.System) – the system to write.

  • ofile (TextIOBase) – the output stream to write to.

Returns

a string representation of the file.

Return type

(str)

write_xyz(system, ofile)[source]

Write out a system to a file in the xyz format.

Parameters
  • system (BigDFT.Systems.System) – the system to write.

  • ofile (TextIOBase) – the output stream to write to.

  • cell (list) – the unit cell.

class XYZReader(filename)[source]

A class which can be used to read from xyz files.

This class should behave like a standard file, which means you can use it in with statements, and use the next command to iterate over it.

closed

check if a file is open or not.

Type

bool

units

the units that the xyz file was in.

Type

str

natoms

the number of atoms in the xyz file.

Type

int

cell

a list of floats describing the cell.

Type

list

Parameters

filename (str) – the file to read from. You can also specify a molecule that might be in the database.

class XYZWriter(filename, natoms, units='angstroem', cell=None)[source]

A class for writing XYZ files.

This class should behave like a standard file, which means you can use it in with statements and write.

Parameters
  • filename (str) – the file to write to.

  • natoms (int) – how many atoms we will write.

  • units (str) – the units of the file. Defaults to angstroem.

  • cell (BigDFT.UnitCells.UnitCell) – the unit cell.

write(atomdict)[source]

Write an atom to the file.

Parameters

atom (dict) – a dictionary describing the atom.